Original multivariate analysis built around

stcox i.HbA1c ib(1).BMI i.smoking i.etoh ib(1).weight_change i.promeat i.ethnicity age sex

Results were decided based on diabetes status (dmdx == 0|1) e.g.

stcox i.HbA1c ib(1).BMI i.smoking i.etoh ib(1).weight_change i.promeat i.ethnicity age sex if dmdx == 0

This produced the following output:


------------------------------------------------------------------------------------
                _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
             HbA1c |
    42-47mmol/mol  |   1.386948   .1867359     2.43   0.015     1.065261    1.805777
     >=48mmol/mol  |    2.16873   .5092706     3.30   0.001     1.368745    3.436278
                   |
               BMI |
                0  |   .7518152   .4371699    -0.49   0.624      .240519    2.350027
                2  |   1.101329   .0908665     1.17   0.242     .9368881    1.294633
                3  |   1.387284   .1308632     3.47   0.001     1.153111    1.669013
                   |
           smoking |
               Ex  |   .9777931   .0729882    -0.30   0.764     .8447114    1.131842
          <20/day  |    1.61776   .1866475     4.17   0.000      1.29035    2.028246
         >=20/day  |   2.890969   .4315232     7.11   0.000     2.157685    3.873458
                   |
              etoh |
Special Occasions  |   .9073865   .1422964    -0.62   0.535     .6672781    1.233894
        1-3/month  |   .7756297   .1298998    -1.52   0.129     .5585964    1.076988
         1-2/week  |   1.008827   .1392919     0.06   0.949     .7696419    1.322345
         3-4/week  |   .9531985   .1349014    -0.34   0.735     .7222991     1.25791
            Daily  |   1.098852   .1535183     0.67   0.500     .8356412     1.44497
                   |
     weight_change |
      Lost weight  |   1.044582   .1015632     0.45   0.654     .8633394    1.263874
    Gained weight  |   .9208174   .0751328    -1.01   0.312     .7847312    1.080503
                   |
           promeat |
          <1/week  |   1.055236   .1455646     0.39   0.697     .8052496    1.382829
           1/week  |   1.031345   .1440162     0.22   0.825     .7844099    1.356017
         2-4/week  |   1.166897   .1642652     1.10   0.273     .8855393    1.537648
         5-6/week  |   1.234044   .2631581     0.99   0.324     .8124809    1.874339
                   |
         ethnicity |
                2  |   1.452587   .6525353     0.83   0.406     .6022306    3.503655
                3  |   .5384152   .2234297    -1.49   0.136     .2387199    1.214356
                4  |   1.090172    .391049     0.24   0.810     .5397167    2.202036
                5  |   1.784799   1.036325     1.00   0.318     .5719364    5.569687
                6  |   1.448003   .5528363     0.97   0.332     .6851529    3.060213
                   |
               age |   1.102496   .0058973    18.24   0.000     1.090998    1.114115
               sex |   1.206323   .0870308     2.60   0.009     1.047256    1.389549
------------------------------------------------------------------------------------

HbA1c, smoking, etoh, processed meat and ethnicity were all categorical variables. BMI and weight change were categorical variables with a different base variable (=1).
Age is a continuous variable. Sex is binary in UKBB.

When carrying out postestimation testing for the proportional-hazards assumption based on Schoenfeld residuals (phtest), then syntax was carried out:
"estat phtest"

 Test of proportional-hazards assumption

      Time:  Time
      ----------------------------------------------------------------
                  |                      chi2       df       Prob>chi2
      ------------+---------------------------------------------------
      global test |                     61.62       26         0.0001


When conducted in those with known diabetes mellitus, i.e. stcox i.HbA1c ib(1).BMI i.smoking i.etoh ib(1).weight_change i.promeat i.ethnicity age sex if dmdx == 1

This produced the following output:



------------------------------------------------------------------------------------
                _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
             HbA1c |
    42-47mmol/mol  |   1.277047   .4258609     0.73   0.463     .6642847    2.455047
     >=48mmol/mol  |   1.947469   .5456578     2.38   0.017     1.124537    3.372618
                   |
               BMI |
                0  |   6.405897   6.678512     1.78   0.075      .830145    49.43175
                2  |   .9808437   .3129353    -0.06   0.952     .5248394    1.833045
                3  |   .7879789   .2507881    -0.75   0.454     .4222841    1.470363
                   |
           smoking |
               Ex  |   1.226731   .2662138     0.94   0.346     .8017326    1.877021
          <20/day  |   1.479941   .5285179     1.10   0.272     .7349579    2.980069
         >=20/day  |   2.405015   .9996707     2.11   0.035     1.064894    5.431615
                   |
              etoh |
Special Occasions  |   1.072594   .3516159     0.21   0.831     .5641521    2.039271
        1-3/month  |   .7153497   .2834387    -0.85   0.398     .3290425    1.555195
         1-2/week  |   .6885614   .2347184    -1.09   0.274     .3530069    1.343081
         3-4/week  |   .8691017   .3097082    -0.39   0.694     .4322562    1.747431
            Daily  |   1.058621   .3647639     0.17   0.869      .538823    2.079864
                   |
     weight_change |
      Lost weight  |   1.808253   .3874172     2.76   0.006     1.188201    2.751875
    Gained weight  |   .8027883   .2220571    -0.79   0.427     .4668233    1.380542
                   |
           promeat |
          <1/week  |   2.155752    1.32828     1.25   0.213      .644356    7.212268
           1/week  |   2.525334   1.544776     1.51   0.130     .7614289    8.375456
         2-4/week  |   1.971945   1.217473     1.10   0.271     .5879838     6.61339
         5-6/week  |   3.658391   2.532464     1.87   0.061     .9420177    14.20761
                   |
         ethnicity |
                2  |   1.683636   1.695566     0.52   0.605     .2338921     12.1194
                3  |   .3916916    .286684    -1.28   0.200     .0933124     1.64418
                4  |   .8426788   .6080252    -0.24   0.812     .2048742    3.466065
                5  |   3.338222   3.382857     1.19   0.234     .4580704    24.32754
                6  |   .6224753   .6287373    -0.47   0.639     .0859721     4.50699
                   |
               age |   1.065323   .0178082     3.79   0.000     1.030985    1.100804
               sex |   1.259967   .2790274     1.04   0.297     .8163109    1.944747
------------------------------------------------------------------------------------

estat phtest

      Test of proportional-hazards assumption

      Time:  Time
      ----------------------------------------------------------------
                  |                      chi2       df       Prob>chi2
      ------------+---------------------------------------------------
      global test |                     31.05       26         0.2263
      ----------------------------------------------------------------


-------------------------------------------------------------------------------------------------------------------------------------------------------


When the values were <0.05; the PH assumption is violated, which led to a time varying coefficient model built around:

stcox i.HbA1c ib(1).BMI i.smoking i.etoh ib(1).weight_change i.promeat i.ethnicity age sex if dmdx == 0, tvc(i.HbA1c) texp(_t) nolog


------------------------------------------------------------------------------------
                _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
main               |
             HbA1c |
    42-47mmol/mol  |   2.292092   .6379876     2.98   0.003      1.32833    3.955105
     >=48mmol/mol  |   12.61132   4.925211     6.49   0.000     5.865885    27.11364
                   |
               BMI |
                0  |   .7523397   .4374748    -0.49   0.625     .2406869    2.351666
                2  |   1.101717   .0908952     1.17   0.240     .9372231    1.295081
                3  |   1.387565   .1308924     3.47   0.001      1.15334    1.669357
                   |
           smoking |
               Ex  |   .9776556   .0729796    -0.30   0.762     .8445896    1.131686
          <20/day  |    1.61777   .1866548     4.17   0.000     1.290348    2.028273
         >=20/day  |   2.886525   .4309457     7.10   0.000     2.154243    3.867729
                   |
              etoh |
Special Occasions  |   .9081114     .14241    -0.61   0.539     .6678112    1.234879
        1-3/month  |   .7767959   .1301005    -1.51   0.132     .5594286    1.078622
         1-2/week  |   1.009464    .139384     0.07   0.946     .7701213     1.32319
         3-4/week  |   .9541338   .1350428    -0.33   0.740     .7229944    1.259168
            Daily  |   1.099858   .1536635     0.68   0.496     .8363992    1.446305
                   |
     weight_change |
      Lost weight  |   1.044196   .1015247     0.44   0.656     .8630215    1.263404
    Gained weight  |   .9203008   .0750916    -1.02   0.309     .7842892    1.079899
                   |
           promeat |
          <1/week  |   1.055228   .1455611     0.39   0.697      .805247    1.382813
           1/week  |   1.031413   .1440238     0.22   0.825     .7844637    1.356101
         2-4/week  |   1.167018   .1642799     1.10   0.273     .8856351    1.537802
         5-6/week  |    1.23324   .2629988     0.98   0.326     .8119359    1.873154
                   |
         ethnicity |
                2  |   1.452389   .6524459     0.83   0.406     .6021487    3.503175
                3  |   .5393636   .2238141    -1.49   0.137     .2391484    1.216454
                4  |   1.092448   .3918594     0.25   0.805     .5408491    2.206609
                5  |   1.783342   1.035484     1.00   0.319     .5714668    5.565169
                6  |   1.449691   .5534863     0.97   0.331     .6859463    3.063803
                   |
               age |   1.102484   .0058972    18.24   0.000     1.090986    1.114103
               sex |   1.205821   .0869934     2.59   0.009     1.046823    1.388969
-------------------+----------------------------------------------------------------
tvc                |
             HbA1c |
    42-47mmol/mol  |   .9169576   .0408525    -1.95   0.052     .8402845    1.000627
     >=48mmol/mol  |   .6784447   .0658584    -4.00   0.000     .5609009    .8206212
------------------------------------------------------------------------------------
Note: Variables in tvc equation interacted with _t.



And then postestimation testing based on the categorical variable for HbA1c (0=<42mmol/mol, 1 = 42-47mmol/mol, 2 = >=48mmol/mol)


What is the HR for hyperglycaemia by time in those not diagnosed with diabetes?
*1 year
lincom _b[main:1.HbA1c] + _b[tvc:1.HbA1c], hr

------------------------------------------------------------------------------
          _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   2.101751   .5051573     3.09   0.002     1.312183    3.366419
------------------------------------------------------------------------------

*2 year
lincom _b[main:1.HbA1c] + 2 * _b[tvc:1.HbA1c], hr

[main]1.HbA1c + 2*[tvc]1.HbA1c = 0

------------------------------------------------------------------------------
          _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   1.927217   .3951119     3.20   0.001     1.289496    2.880323
------------------------------------------------------------------------------

*3 year
lincom _b[main:1.HbA1c] + 3 * _b[tvc:1.HbA1c], hr

[main]1.HbA1c + 3*[tvc]1.HbA1c = 0

------------------------------------------------------------------------------
          _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   1.767176   .3074336     3.27   0.001       1.2566    2.485206
------------------------------------------------------------------------------

etc




What is the HR for HbA1c in the diabetic range in those not diagnosed with diabetes?
*1 year
lincom _b[main:2.HbA1c] + _b[tvc:2.HbA1c], hr

[main]2.HbA1c + [tvc]2.HbA1c = 0

------------------------------------------------------------------------------
          _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   8.556086   2.731044     6.73   0.000     4.576963    15.99458
------------------------------------------------------------------------------


*2 year
lincom _b[main:2.HbA1c] + 2 * _b[tvc:2.HbA1c], hr

[main]2.HbA1c + 2*[tvc]2.HbA1c = 0

------------------------------------------------------------------------------
          _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   5.804832   1.536847     6.64   0.000     3.454867    9.753217



*3 year
lincom _b[main:2.HbA1c] + 3 * _b[tvc:2.HbA1c], hr

[main]2.HbA1c + 3*[tvc]2.HbA1c = 0

------------------------------------------------------------------------------
          _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   3.938257   .9414848     5.73   0.000     2.464988    6.292068


etc